/**
 * 
 */
package fr.cephb.operonj.core.db.comparator;

import java.io.Serializable;
import java.util.Comparator;

import com.sleepycat.bind.tuple.TupleInput;

import fr.cephb.operonj.core.db.binding.BuildChromBinding;
import fr.cephb.operonj.core.db.key.BuildChrom;


/**
 * @author pierre
 *
 */
public class BuildChromComparator
	implements Comparator<byte[]>,Serializable
	{
	private static final long serialVersionUID = 1L;
	public BuildChromComparator()
		{
		}
	
	@Override
	public int compare(byte[] o1, byte[] o2)
		{
		BuildChromBinding binding= new BuildChromBinding();
		BuildChrom t1= binding.entryToObject(new TupleInput(o1));
		BuildChrom t2= binding.entryToObject(new TupleInput(o2));
		int n=t1.getBuildId()-t2.getBuildId();
		if(n!=0) return n;
		return t1.getChromId()-t2.getChromId();
		}
	}
